package com.joysuch.wwyt.bp.entity;


import com.joysuch.wwyt.core.support.AutoSetCommonFieldListener;
import lombok.Data;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.hibernate.annotations.Proxy;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDate;
import java.util.Date;

import static javax.persistence.GenerationType.IDENTITY;

@EntityListeners({AuditingEntityListener.class, AutoSetCommonFieldListener.class})
@Entity
@Table(name = "wwyt_bp_emergency_exercise_plan")
@SQLDelete(sql = "update wwyt_bp_emergency_exercise_plan set DELETE_FLAG = '1' where id= ?")
@SQLDeleteAll(sql = "update wwyt_bp_emergency_exercise_plan set DELETE_FLAG = '1' where id= ?")
@Where(clause = "DELETE_FLAG = '0'")
@Data
@Proxy(lazy = false)
public class BpEmergencyExercisePlan implements Serializable {

    //演练计划id
    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "ID", unique = true, nullable = false)
    private Long id;

    //编码
    @Column(name = "CODE")
    private String code;

    //名称
    @Column(name = "NAME")
    private String name;

    //演练地点
    @Column(name = "LOCATION")
    private String location;

    //主办部门
    @Column(name = "DEPART_ID")
    private Long departId;

    //演练方式
    @Column(name = "METHOD")
    private Long method;

    //演练级别
    @Column(name = "LEVEL")
    private Long level;

    //应急预案(制度id)
    @Column(name = "PID")
    private Long pid;

    //制定人
    @Column(name = "DESIGENER_ID")
    private Long desigenerId;

    //制定日期
    @Column(name = "ENACTMENT_DATE")
    private LocalDate enacymentDate;

    //开始日期
    @Column(name = "START_DATE")
    private LocalDate startDate;

    //结束日期
    @Column(name = "END_DATE")
    private LocalDate endDate;

    //演练内容
    @Column(name = "CONTENT")
    private String content;

    //备注
    @Column(name = "NOTE")
    private String note;

    //附件
    @Column(name = "ATTACHMENT_ID")
    private String attachmentId;

    @org.springframework.data.annotation.CreatedBy
    @Column(name = "CREATE_BY")
    private Long createBy;

    @org.springframework.data.annotation.CreatedDate
    @Column(name = "CREATE_TIME")
    private Date createTime;

    @org.springframework.data.annotation.LastModifiedBy
    @Column(name = "UPDATE_BY")
    private Long updateBy;

    @org.springframework.data.annotation.LastModifiedDate
    @Column(name = "UPDATE_TIME")
    private Date updateTime;

    @Column(name = "DELETE_FLAG")
    private String deleteFlag;

    @Column(name = "ORG_CODE")
    private String orgCode;

    @Column(name = "TENENT_ID")
    private Long tenentId;

    public int hashCode() {
        return new HashCodeBuilder().append(getId()).toHashCode();
    }

    public boolean equals(Object obj) {
        if (obj instanceof BpEmergencyExercisePlan == false)
            return false;
        if (this == obj)
            return true;
        BpEmergencyExercisePlan other = (BpEmergencyExercisePlan) obj;
        return new EqualsBuilder().append(getId(), other.getId()).isEquals();
    }
}
